package com.movefeng.hexoblogadmin.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import com.movefeng.hexoblogadmin.service.UserService;
import com.movefeng.hexoblogadmin.vo.Result;
import com.movefeng.hexoblogadmin.vo.UserVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * @author csp1999
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private HttpServletRequest request;

    @Resource
    private HttpServletResponse response;

    @Resource
    private UserService userService;

   @PostMapping("list")
    public Result userList(@RequestParam("pageNum") int pageNum, @RequestParam("pageSize") int pageSize,@RequestBody(required = false) Map<String, Object> searchParam){
       if (searchParam == null) {
           searchParam = new HashMap<>();
       }

       Page<UserVO> page = userService.queryUserList(searchParam);

       PageInfo<UserVO> pageInfo = new PageInfo<>(page);

       return new Result<>(Result.Code.SUCCESS, pageInfo);
   }
}
